﻿using Autofac;
using LiuQiuRong.Chat.Infrastructures.DataStore;
using SqlSugar;

namespace LiuQiuRong.Chat.Infrastructures.Modules
{
    /// <summary>
    /// 数据访问器批量注册模块
    /// </summary>
    public class DataAccessorModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType<DataAccessor>().As<IDataAccessor>().InstancePerLifetimeScope();    // 注册数据库访问器，并设置基于请求创建
            builder.RegisterType<SqlSugarClient>().As<ISqlSugarClient>().WithParameter(new TypedParameter(typeof(ConnectionConfig), new ConnectionConfig()
            {
                DbType = DbType.Sqlite
            })).InstancePerLifetimeScope(); // 注册数据库操作对象，设置基于请求创建
        }
    }
}
